<?php

use yii\helpers\Html;
use eric\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\models\Channel */
/* @var $form eric\widgets\ActiveForm */
?>
<div class="channel-form">

    <?php $form = ActiveForm::begin([
        'ajaxSubmitSuccess' => "function(data){\$('#channel_modal').modal('hide');\$.pjax.reload('#channel_grid_pjax');}",
        'options' => [
            'id' => 'channel_form',
            'class' => 'form-horizontal form-bordered',
        ]
    ]); ?>

    <?= $form->field($model, 'cname')->textInput(['maxlength' => 128]) ?>

    <?php
//    if($model->isNewRecord){
        echo $form->field($model, 'fid')->dropDownList(['0'=>'请选择']+$model->getChannel_str());
//    }else{
//       echo <<<HTML
//           <div class="form-group field-channel_fid has-success">
//<label class="col-md-2 control-label" for="channel_fid">父类</label>
//<div class="col-md-10">
//<select id="channel_fid" class="form-control" name="Channel[fid]">
//      {$model->getChannel($id)}
//      </select>
//</div>
//
//HTML;
//
//    }

    ?>

    <?php
//    if($model->getChannel_str() ==NULL){
//        echo "";
//    }else{
//        echo $model->getChannel_str();
//
//
//    }
    ?>

    <?php if(!isset($model->type)) $model->type=1;?>
    <?= $form->field($model, 'type')->radioList($model::$type_array) ?>

    <?php $data=$model->readDir()?>
    <?= $form->field($model, 'list_template')->dropDownList($data) ?>

    <?= $form->field($model, 'show_template')->dropDownList($model->readShow()) ?>

    <?php if(!isset($model->display)) $model->display=1;?>
    <?= $form->field($model, 'display')->radioList($model::$display_array) ?>

    <?= $form->field($model, 'seq')->textInput(['maxlength' => 11,'placeholder'=>'数值越大,频道顺序就越靠前']) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', '添加') : Yii::t('app', '修改'), ['class' => $model->isNewRecord ? 'btn btn-support1' : 'btn btn-support3']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
